﻿@model DHQGHN.PM2.Models.EnumeratorModel
@{
    if (ViewBag.Admin != null)
    {
        ViewBag.Title = "Quản lý Admin Xã/Phường";
        ViewBag.Group = "Quản lý chung";
    }
    else { 
    ViewBag.Title = "Quản lý cán bộ nghiệp vụ";
    ViewBag.Root = "Quản lý chung";
    }
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<script>
    @functions{
        public string GetAntiForgeryToken()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + "," + formToken;
        }
    }

    $(function () {
        $("#btnDelete").click(function () {
            var enumID = $("#ENUMERATOR_ID").val();
            var result = confirm("Bạn có chắc chắn xóa không?");
            if ('@ViewBag.Admin' != '') {
                if (result) {
                    $.ajax({
                        cache: false,
                        url: '@Url.Action("DeleteAdmin")',
                        type: 'POST',
                        headers: {
                            'VerificationToken': '@GetAntiForgeryToken()'
                        },
                        data: {
                            id: enumID
                        },
                        success: function (dataResult) {
                            window.location.href = '@Url.Action("SearchAdmin")';
                        },
                        error: function (ex) {
                            alert("Co loi xay ra: \n" + JSON.stringify(ex));
                        }
                    });

                }
            }
            else {
                if (result) {
                    $.ajax({
                        cache: false,
                        url: '@Url.Action("Delete")',
                        type: 'POST',
                        headers: {
                            'VerificationToken': '@GetAntiForgeryToken()'
                        },
                        data: {
                            id: enumID
                        },
                        success: function (dataResult) {
                            window.location.href = '@Url.Action("Details")';
                        },
                        error: function (ex) {
                            alert("Co loi xay ra: \n" + JSON.stringify(ex));
                        }
                    });

                }
            }
        });
    });
</script>

@Html.AntiForgeryToken()
<div class="row">
    <div class="col-md-6">
        @Html.HiddenFor(model => model.ENUMERATOR_ID)
        <fieldset id="fs1" class="fs_group1" style="border-style:hidden;">
            <legend>Thông tin của bản ghi cần xóa</legend>
            @*@Html.Partial("EditPartial", Model)*@

            @Html.HiddenFor(m => m.ADM_CODE)
            @Html.HiddenFor(m => m.ADM_UNIT_ID)
            @Html.HiddenFor(m => m.GROUP_CODE_OLD)
            <div class="row">
                <div class="col-md-12">
                    @Html.LabelFor(m => m.FULL_NAME, new { @class = "text-center" })
                    @Html.DisplayFor(m => m.FULL_NAME, new { @class = "form-control ", style = "", @maxlength = 50 })
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    @Html.LabelFor(m => m.USERNAME, new { @class = "text-center" })
                    @Html.DisplayFor(m => m.USERNAME, new { @class = "form-control ", style = "" })
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    @Html.LabelFor(m => m.GROUPCODE, new { @class = "text-center" })
                    @Html.DisplayFor(m => m.GROUPCODE, new { @class = "form-control ", style = "" })
                </div>
            </div>

            <div class="row">
                <div class="col-md-12" style="text-overflow:ellipsis; overflow:hidden;">
                    @Html.LabelFor(mode => mode.DESCRIPTIONS, new { @class = "text-center" })
                    @Html.DisplayFor(m => m.DESCRIPTIONS, new { @class = "form-control ", @rows = 3, style = "  max-width: 100%;" })
                </div>
            </div>

            <div class="btn-group-detail" style="margin-top:10px;">
                <button id="btnDelete" class="btn btn-md btn-default">Xóa</button>
                @if (ViewBag.Admin != null)
                {
                    <input type="button" class="btn btn-md btn-default" value="Quay lại" onclick="window.location.href='@Url.Action("SearchAdmin")';">
                }
                else
                {
                    <input type="button" class="btn btn-md btn-default" value="Quay lại" onclick="window.location.href='@Url.Action("Details")';">
                }
            </div>
        </fieldset>

    </div>
</div>

